package com.wf.it.hpplan.service.impl;

import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.wf.it.common.api.PlanService;
import com.wf.it.common.entity.Plan;
import com.wf.it.common.vo.Result;
import com.wf.it.hpplan.dao.PlanDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class PlanServiceImpl implements PlanService {
    @Autowired
    private PlanDao dao;
    @Override
    public Result<List<Plan>> findByDocId(String empno) {
        List<Plan> list= dao.findByDocEmpNo(empno);
        return new Result<>(list);
    }

    @Override
    public Result<Plan> findById(int planid) {
        Plan p=dao.findById(planid).get();
        return new Result<>(p);
    }

    @Override
    @LcnTransaction
    @Transactional(isolation = Isolation.SERIALIZABLE)
    public Result updateBookCount(int planid, int num) {
        dao.updateBookCount(planid,num);
        return new Result();
    }
}
